package com.my.study;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class CompanyProblems {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        List<String> res = new ArrayList<>();
        while (scanner.hasNext()){

            String waitCalculate = scanner.next();

            int a = waitCalculate.charAt(0) - '0';
            int b = waitCalculate.charAt(2) - '0';
            int c = waitCalculate.charAt(4) - '0';
            int d = waitCalculate.charAt(6) - '0';

            int fenmu = b * d;
            int fenzi = 0;

            StringBuilder sb = new StringBuilder();
            if(waitCalculate.charAt(3) == '+'){
                fenzi = a * d + c * b;
            }else{
                fenzi = a * d - c * b;
                if(fenzi < 0){
                    sb.append("-");
                }
                fenzi = Math.abs(fenzi);
            }

            if(fenzi == 0){
                res.add("0");
            }else if(fenzi == fenmu) {
                res.add("1");
            }
            else{
                int max = findMaxGongyueshu(fenzi, fenmu);
                sb.append(fenzi / max).append("/").append(fenmu/max);
                res.add(sb.toString());
                System.out.println("=====" + sb.toString());
            }
            System.out.println(res);
        }
        for(String r : res){
            System.out.println(r);
        }

        //System.out.println(findMaxGongyueshu(4,8));
    }


    public static int findMaxGongyueshu(int a, int b){
        if(a == b){
            return a;
        }

        if(a > b){
            int tmp  = b;
            b = a;
            a = tmp;
        }

        int max = 1;
        for(int i = 2;i <= a;i++){

            if(a % i == 0 && b % i == 0){
                max = Math.max(i, max);
            }
        }
        return max;
    }
}
